/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  						 path_arrow.cpp

	$Header: /heroes4/path_arrow.cpp $

	$NoKeywords: $

 ************************************************************************/

// kill the 255+ character identifier warning.  Templates tend to exceed that easily.
#include "precompiled.h"
#pragma warning( disable: 4786 )

#include "path_arrow.h"

enum t_bend
{
	k_straight,
	k_right_45,
	k_right_90,
	k_right_135,
	k_reverse,
	k_left_135,
	k_left_90,
	k_left_45
};

static char const* k_model_name[k_path_arrow_color_count][8][9] =
{
	// green
	{
		{	// straight
			{ "internal.green_arrow.straight.ne" },
			{ "internal.green_arrow.straight.e" },
			{ "internal.green_arrow.straight.se" },
			{ "internal.green_arrow.straight.s" },
			{ "internal.green_arrow.straight.sw" },
			{ "internal.green_arrow.straight.w" },
			{ "internal.green_arrow.straight.nw" },
			{ "internal.green_arrow.straight.n" },
			{ "internal.green_arrow.dest" },
		},
		{	// right_45
			{ "internal.green_arrow.right.ne" },
			{ "internal.green_arrow.right.e" },
			{ "internal.green_arrow.right.se" },
			{ "internal.green_arrow.right.s" },
			{ "internal.green_arrow.right.sw" },
			{ "internal.green_arrow.right.w" },
			{ "internal.green_arrow.right.nw" },
			{ "internal.green_arrow.right.n" },
			{ "internal.green_arrow.dest" },
		},
		{  // right_90
			{ "internal.green_arrow.straight.se" },
			{ "internal.green_arrow.straight.s" },
			{ "internal.green_arrow.straight.sw" },
			{ "internal.green_arrow.straight.w" },
			{ "internal.green_arrow.straight.nw" },
			{ "internal.green_arrow.straight.n" },
			{ "internal.green_arrow.straight.ne" },
			{ "internal.green_arrow.straight.e" },
			{ "internal.green_arrow.dest" },
		},
		{  // right_135
			{ "internal.green_arrow.straight.s" },
			{ "internal.green_arrow.straight.sw" },
			{ "internal.green_arrow.straight.w" },
			{ "internal.green_arrow.straight.nw" },
			{ "internal.green_arrow.straight.n" },
			{ "internal.green_arrow.straight.ne" },
			{ "internal.green_arrow.straight.e" },
			{ "internal.green_arrow.straight.se" },
			{ "internal.green_arrow.dest" },
		},
		{  // reverse
			{ "internal.green_arrow.straight.sw" },
			{ "internal.green_arrow.straight.w" },
			{ "internal.green_arrow.straight.nw" },
			{ "internal.green_arrow.straight.n" },
			{ "internal.green_arrow.straight.ne" },
			{ "internal.green_arrow.straight.e" },
			{ "internal.green_arrow.straight.se" },
			{ "internal.green_arrow.straight.s" },
			{ "internal.green_arrow.dest" },
		},
		{  // left_135
			{ "internal.green_arrow.straight.w" },
			{ "internal.green_arrow.straight.nw" },
			{ "internal.green_arrow.straight.n" },
			{ "internal.green_arrow.straight.ne" },
			{ "internal.green_arrow.straight.e" },
			{ "internal.green_arrow.straight.se" },
			{ "internal.green_arrow.straight.s" },
			{ "internal.green_arrow.straight.sw" },
			{ "internal.green_arrow.dest" },
		},
		{  // left_90
			{ "internal.green_arrow.straight.nw" },
			{ "internal.green_arrow.straight.n" },
			{ "internal.green_arrow.straight.ne" },
			{ "internal.green_arrow.straight.e" },
			{ "internal.green_arrow.straight.se" },
			{ "internal.green_arrow.straight.s" },
			{ "internal.green_arrow.straight.sw" },
			{ "internal.green_arrow.straight.w" },
			{ "internal.green_arrow.dest" },
		},
		{  // left_45
			{ "internal.green_arrow.left.ne" },
			{ "internal.green_arrow.left.e" },
			{ "internal.green_arrow.left.se" },
			{ "internal.green_arrow.left.s" },
			{ "internal.green_arrow.left.sw" },
			{ "internal.green_arrow.left.w" },
			{ "internal.green_arrow.left.nw" },
			{ "internal.green_arrow.left.n" },
			{ "internal.green_arrow.dest" },
		},
	},
	// yellow
	{
		{	// straight
			{ "internal.yellow_arrow.straight.ne" },
			{ "internal.yellow_arrow.straight.e" },
			{ "internal.yellow_arrow.straight.se" },
			{ "internal.yellow_arrow.straight.s" },
			{ "internal.yellow_arrow.straight.sw" },
			{ "internal.yellow_arrow.straight.w" },
			{ "internal.yellow_arrow.straight.nw" },
			{ "internal.yellow_arrow.straight.n" },
			{ "internal.yellow_arrow.dest" },
		},
		{	// right_45
			{ "internal.yellow_arrow.right.ne" },
			{ "internal.yellow_arrow.right.e" },
			{ "internal.yellow_arrow.right.se" },
			{ "internal.yellow_arrow.right.s" },
			{ "internal.yellow_arrow.right.sw" },
			{ "internal.yellow_arrow.right.w" },
			{ "internal.yellow_arrow.right.nw" },
			{ "internal.yellow_arrow.right.n" },
			{ "internal.yellow_arrow.dest" },
		},
		{  // right_90
			{ "internal.yellow_arrow.straight.se" },
			{ "internal.yellow_arrow.straight.s" },
			{ "internal.yellow_arrow.straight.sw" },
			{ "internal.yellow_arrow.straight.w" },
			{ "internal.yellow_arrow.straight.nw" },
			{ "internal.yellow_arrow.straight.n" },
			{ "internal.yellow_arrow.straight.ne" },
			{ "internal.yellow_arrow.straight.e" },
			{ "internal.yellow_arrow.dest" },
		},
		{  // right_135
			{ "internal.yellow_arrow.straight.s" },
			{ "internal.yellow_arrow.straight.sw" },
			{ "internal.yellow_arrow.straight.w" },
			{ "internal.yellow_arrow.straight.nw" },
			{ "internal.yellow_arrow.straight.n" },
			{ "internal.yellow_arrow.straight.ne" },
			{ "internal.yellow_arrow.straight.e" },
			{ "internal.yellow_arrow.straight.se" },
			{ "internal.yellow_arrow.dest" },
		},
		{  // reverse
			{ "internal.yellow_arrow.straight.sw" },
			{ "internal.yellow_arrow.straight.w" },
			{ "internal.yellow_arrow.straight.nw" },
			{ "internal.yellow_arrow.straight.n" },
			{ "internal.yellow_arrow.straight.ne" },
			{ "internal.yellow_arrow.straight.e" },
			{ "internal.yellow_arrow.straight.se" },
			{ "internal.yellow_arrow.straight.s" },
			{ "internal.yellow_arrow.dest" },
		},
		{  // left_135
			{ "internal.yellow_arrow.straight.w" },
			{ "internal.yellow_arrow.straight.nw" },
			{ "internal.yellow_arrow.straight.n" },
			{ "internal.yellow_arrow.straight.ne" },
			{ "internal.yellow_arrow.straight.e" },
			{ "internal.yellow_arrow.straight.se" },
			{ "internal.yellow_arrow.straight.s" },
			{ "internal.yellow_arrow.straight.sw" },
			{ "internal.yellow_arrow.dest" },
		},
		{  // left_90
			{ "internal.yellow_arrow.straight.nw" },
			{ "internal.yellow_arrow.straight.n" },
			{ "internal.yellow_arrow.straight.ne" },
			{ "internal.yellow_arrow.straight.e" },
			{ "internal.yellow_arrow.straight.se" },
			{ "internal.yellow_arrow.straight.s" },
			{ "internal.yellow_arrow.straight.sw" },
			{ "internal.yellow_arrow.straight.w" },
			{ "internal.yellow_arrow.dest" },
		},
		{  // left_45
			{ "internal.yellow_arrow.left.ne" },
			{ "internal.yellow_arrow.left.e" },
			{ "internal.yellow_arrow.left.se" },
			{ "internal.yellow_arrow.left.s" },
			{ "internal.yellow_arrow.left.sw" },
			{ "internal.yellow_arrow.left.w" },
			{ "internal.yellow_arrow.left.nw" },
			{ "internal.yellow_arrow.left.n" },
			{ "internal.yellow_arrow.dest" },
		},
	},
	{	// red
		{	// straight
			{ "internal.red_arrow.straight.ne" },
			{ "internal.red_arrow.straight.e" },
			{ "internal.red_arrow.straight.se" },
			{ "internal.red_arrow.straight.s" },
			{ "internal.red_arrow.straight.sw" },
			{ "internal.red_arrow.straight.w" },
			{ "internal.red_arrow.straight.nw" },
			{ "internal.red_arrow.straight.n" },
			{ "internal.red_arrow.dest" },
		},
		{	// right_45
			{ "internal.red_arrow.right.ne" },
			{ "internal.red_arrow.right.e" },
			{ "internal.red_arrow.right.se" },
			{ "internal.red_arrow.right.s" },
			{ "internal.red_arrow.right.sw" },
			{ "internal.red_arrow.right.w" },
			{ "internal.red_arrow.right.nw" },
			{ "internal.red_arrow.right.n" },
			{ "internal.red_arrow.dest" },
		},
		{  // right_90
			{ "internal.red_arrow.straight.se" },
			{ "internal.red_arrow.straight.s" },
			{ "internal.red_arrow.straight.sw" },
			{ "internal.red_arrow.straight.w" },
			{ "internal.red_arrow.straight.nw" },
			{ "internal.red_arrow.straight.n" },
			{ "internal.red_arrow.straight.ne" },
			{ "internal.red_arrow.straight.e" },
			{ "internal.red_arrow.dest" },
		},
		{  // right_135
			{ "internal.red_arrow.straight.s" },
			{ "internal.red_arrow.straight.sw" },
			{ "internal.red_arrow.straight.w" },
			{ "internal.red_arrow.straight.nw" },
			{ "internal.red_arrow.straight.n" },
			{ "internal.red_arrow.straight.ne" },
			{ "internal.red_arrow.straight.e" },
			{ "internal.red_arrow.straight.se" },
			{ "internal.red_arrow.dest" },
		},
		{  // reverse
			{ "internal.red_arrow.straight.sw" },
			{ "internal.red_arrow.straight.w" },
			{ "internal.red_arrow.straight.nw" },
			{ "internal.red_arrow.straight.n" },
			{ "internal.red_arrow.straight.ne" },
			{ "internal.red_arrow.straight.e" },
			{ "internal.red_arrow.straight.se" },
			{ "internal.red_arrow.straight.s" },
			{ "internal.red_arrow.dest" },
		},
		{  // left_135
			{ "internal.red_arrow.straight.w" },
			{ "internal.red_arrow.straight.nw" },
			{ "internal.red_arrow.straight.n" },
			{ "internal.red_arrow.straight.ne" },
			{ "internal.red_arrow.straight.e" },
			{ "internal.red_arrow.straight.se" },
			{ "internal.red_arrow.straight.s" },
			{ "internal.red_arrow.straight.sw" },
			{ "internal.red_arrow.dest" },
		},
		{  // left_90
			{ "internal.red_arrow.straight.nw" },
			{ "internal.red_arrow.straight.n" },
			{ "internal.red_arrow.straight.ne" },
			{ "internal.red_arrow.straight.e" },
			{ "internal.red_arrow.straight.se" },
			{ "internal.red_arrow.straight.s" },
			{ "internal.red_arrow.straight.sw" },
			{ "internal.red_arrow.straight.w" },
			{ "internal.red_arrow.dest" },
		},
		{  // left_45
			{ "internal.red_arrow.left.ne" },
			{ "internal.red_arrow.left.e" },
			{ "internal.red_arrow.left.se" },
			{ "internal.red_arrow.left.s" },
			{ "internal.red_arrow.left.sw" },
			{ "internal.red_arrow.left.w" },
			{ "internal.red_arrow.left.nw" },
			{ "internal.red_arrow.left.n" },
			{ "internal.red_arrow.dest" },
		},
	},
};


static std::string get_model_name(  t_direction direction, t_direction turn, 
									t_path_arrow_color color )
{
	t_bend bend = t_bend( (turn + 8 - direction) & 7 );

	return k_model_name[color][bend][direction];
}

// -------------------------------------------------------------------------------
// t_stationary_adventure_object class
// -------------------------------------------------------------------------------

t_path_arrow::t_path_arrow( t_direction direction, t_direction turn, t_path_arrow_color color )
	        : t_stationary_adventure_object( ::get_model_name( direction, turn, color ) )
{
}

	// Member functions
// -------------------------------------------------------------------------------
// t_stationary_adventure_object class
// -------------------------------------------------------------------------------
std::auto_ptr< t_abstract_adv_object > t_path_arrow::clone() const
{
	return std::auto_ptr< t_abstract_adv_object >(new t_path_arrow( *this ));
}

// -------------------------------------------------------------------------------
// t_stationary_adventure_object class
// -------------------------------------------------------------------------------
std::string t_path_arrow::get_name() const
{
	return "";
}

/////////////////////////////////////////////////////////////////////////////
bool t_path_arrow::is_event_recordable() const
{
	return false;
}
